import logging
from redis import StrictRedis


class Config(object):
    """项目的配置"""
    DEBUG = True


    SECRET_KEY = '4EQB3cqXCSe+FMxicxHvX1kR9XW1EurHwFh8gY+EuBbjSbhnI3imDN753h1ZeRWr'

    # 数据库到配置信息
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/flask_01'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis 到配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # session 保存配置
    SESSION_TYPE = 'redis'
    # 开启session签名
    SESSION_USE_SIQNER = True
    # 指定 Session 保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    # 设置需要过期
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发环境下的配置"""
    DEBUG = True

class ProductionConfig(Config):
    """生产环境下到配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """单元测试环境下到配置"""
    DEBUG = True
    TESTING = True

config = {
    'development':DevelopmentConfig,
    'production':ProductionConfig,
    'testing':TestingConfig,
}